<template>
    门店名称:
    <input type="text" v-model="ff.name"/>
    <input type="button" value="查询" @click="show()"/>
    <table class="table table-border" border="1">
        <tr>
            <td>门店名称</td>
            <td>分店名称</td>
            <td>分店地址</td>
            <td>门店电话</td>
            <td>门店信息</td>
            <td>门店状态</td>
            <td>时间</td>
            <td>操作</td>
        </tr>
        <tr v-for="item in info">
            <td>{{ item.name }}</td>
            <td>{{ item.deName }}</td>
            <td>{{ item.aderr }}</td>
            <td>{{ item.phone }}</td>
            <td>{{ item.info }}</td>
            <td>{{ item.state==true?"营业":"停业" }}</td>
            <td>{{ item.ctime.substring(0,10) }}  {{ item.ctime.substring(11,16) }}</td>
            <td>
                <input type="button" value="详情页" @click="upd(item.id)"/>
            </td>
        </tr>
    </table>
    <span>
        共{{ ff.totalcount }}条,每页{{ ff.size }}条,当前第{{ ff.index }}/{{ ff.totalpage }}页
        <input type="button" value="首页" @click="fenye(1)"/>
        <input type="button" value="上一页" @click="fenye(ff.index-1)"/>
        <input type="button" value="下一页" @click="fenye(ff.index+1)"/>
        <input type="button" value="尾页" @click="fenye(ff.totalpage)"/>
    </span>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
import Userupd from './userupd.vue';
import router from '@/router';
const info=ref([{
      "id": 0,
      "name": "",
      "aderr": "",
      "deName": "",
      "phone": "",
      "info": "",
      "state": true,
      "ctime": "",
}])
const ff=ref({
    index:1,
    size:2,
    totalcount:0,
    totalpage:0,
    name:""
})
onMounted(()=>{
    show();
})
const fenye=(p:number)=>{
if(p<1){
    p=1;
    alert('当前已经是是第一页');
    return;
}
if(p>ff.value.totalpage){
    p=ff.value.totalpage;
    alert('当前已经是最后一页');
    return;
}
ff.value.index=p;
show();
}
const show=()=>{
    axios.get("https://localhost:7184/api/user/userlist?index="+ff.value.index+"&size="+ff.value.size+"&name="+ff.value.name).then(res=>{
        info.value=res.data.dateinfo;
        ff.value.totalcount=res.data.totalcount;
        ff.value.totalpage=res.data.pagecount;
    }
    )
}
const upd=(id:number)=>{
    router.push("/userupd?id="+id);
}
</script>

